#include <iostream>
#include <thread>
#include <string>
#include <vector>
#include <memory>

class big_object
{
public:
    big_object() = default;
    big_object(std::vector<std::string> strVec) : m_strVect(strVec) {}
    ~big_object()
    {
        if (!m_strVect.empty())
        {
            m_strVect.clear();
        }
    }

    void toString()
    {
        for (const auto &vec : m_strVect)
        {
            std::cout << vec << " ";
        }
        std::cout << std::endl;
    }

    void set_data(std::string str)
    {
        m_strVect.push_back(str);
    }

private:
    std::vector<std::string> m_strVect;
};

void process_big_object(std::unique_ptr<big_object> big_object)
{
    big_object->set_data("process big object");
}

int main()
{
    std::unique_ptr<big_object> big_object_ptr = std::make_unique<big_object>();
    std::unique_ptr<big_object> p(new big_object());
    big_object_ptr->set_data(std::string("message"));
    big_object_ptr->toString();

    // 所有权转移
    std::thread t(process_big_object, std::move(big_object_ptr));
    // 这里会报错，因为上一步把所有权转移了，这里 big_object_ptr 不能再次被调用
    // big_object_ptr->toString();

    t.join();

    return 0;
}